﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using l1cs.server.model.Instance;
using l1cs.server.model;

namespace l1cs.server.serverpackets
{
    public class S_Buddy : ServerBasePacket
    {
        private static String _HTMLID = "buddy";

        private byte[] _byte = null;

        public S_Buddy( int objId, L1Buddy buddy )
        {
            buildPacket( objId, buddy );
        }

        private void buildPacket( int objId, L1Buddy buddy )
        {
            writeC( Opcodes.S_OPCODE_SHOWHTML );
            writeD( objId );
            writeS( _HTMLID );
            writeH( 0x02 );
            writeH( 0x02 );

            writeS( buddy.getBuddyListString() );
            writeS( buddy.getOnlineBuddyListString() );
        }

        override
        public byte[] getContent()
        {
            if ( _byte == null )
            {
                _byte = _bao.ToArray();
            }
            return _byte;
        }

        override
        public String getType()
        {
            return "[S] _S_Buddy";
        }
    }
}